home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / os2 / gnucal.zip / gcal_rcu.c < prev    next >
C/C++ Source or Header  |  1995-12-20  |  63KB  |  1,673 lines

  1. /*
  2. *  gcal_rcu.c:  Central function, manages RC-file handling and displays the list
  3. *
  4. *
  5. *  Copyright (C) 1994, 1995 Thomas Esken
  6. *
  7. *  This software doesn't claim completeness, correctness or usability.
  8. *  On principle I will not be liable for any damages or losses (implicit
  9. *  or explicit), which result from using or handling my software.
  10. *  If you use this software, you agree without any exception to this
  11. *  agreement, which binds you LEGALLY !!
  12. *
  13. *  This program is free software; you can redistribute it and/or modify
  14. *  it under the terms of the `GNU General Public License' as published by
  15. *  the `Free Software Foundation'; either version 2, or (at your option)
  16. *  any later version.
  17. *
  18. *  You should have received a copy of the `GNU General Public License'
  19. *  along with this program; if not, write to the:
  20. *    Free Software Foundation
  21. *    59 Temple Place, Suite 330
  22. *    Boston, MA 02111-1307  USA
  23. */
  24.  
  25.  
  26.  
  27. /*
  28. *  Include definition header file to see whether USE_RC is defined there.
  29. *    compile this module only if USE_RC is defined, otherwise skip it.
  30. */
  31. #include "gcal_tai.h"
  32.  
  33.  
  34.  
  35. #if USE_RC
  36. #  ifdef RCSID
  37. static char rcsid[]="$Id: gcal_rcu.c 0.39 1995/12/20 00:03:09 tom Exp $";
  38. #  endif
  39.  
  40.  
  41.  
  42. /*
  43. *  Include header files
  44. */
  45. #  if HAVE_ASSERT_H
  46. #    include <assert.h>
  47. #  endif
  48. #  if HAVE_CTYPE_H
  49. #    include <ctype.h>
  50. #  endif
  51. #  include "gcal.h"
  52.  
  53.  
  54.  
  55. /*
  56. *  Function prototypes
  57. */
  58. #  if __cplusplus
  59. extern "C"
  60. {
  61. #  endif
  62. /*
  63. ************************************************** Defined in `gcal_fil.c'
  64. */
  65. IMPORT FILE *
  66. file_open __P_((      char       *filename,
  67.                 const Fmode_enum  mode));
  68. IMPORT char *
  69. file_read_line __P_((      FILE       *fp,
  70.                            char       *line_buffer,
  71.                            int        *in_pool,
  72.                            char       *pool,
  73.                            char       *ptr_pool,
  74.                      const char       *filename,
  75.                            int        *line,
  76.                      const Fmode_enum  mode,
  77.                            Bool       *is_include,
  78.                            Bool       *is_dvar));
  79. /*
  80. ************************************************** Defined in `gcal_hdy.c'
  81. */
  82. IMPORT void
  83. print_all_holidays __P_((      Bool init_data,
  84.                          const Bool detect));
  85. /*
  86. ************************************************** Defined in `gcal_rc.c'
  87. */
  88. IMPORT void
  89. rc_clean_flags __P_((void));
  90. IMPORT char *
  91. rc_get_date __P_((      char *ptr_char,
  92.                         Bool *is_weekday_mode,
  93.                         int  *d,
  94.                         int  *m,
  95.                         int  *y,
  96.                         int  *n,
  97.                         int  *len,
  98.                         char *hc,
  99.                         int  *hn,
  100.                         int  *hwd,
  101.                   const char *filename,
  102.                   const int   line,
  103.                   const char *line_buffer,
  104.                   const Bool  on_error_exit));
  105. /*
  106. ************************************************** Defined in `gcal_rcc.c'
  107. */
  108. IMPORT void
  109. rc_check __P_((      char *line_buffer,
  110.                const char *filename,
  111.                      int  *line,
  112.                      int  *rc_elems,
  113.                      int   day,
  114.                      int   ed,
  115.                const int   wd));
  116. /*
  117. ************************************************** Defined in `gcal_tty.c'
  118. */
  119. IMPORT void
  120. print_text __P_((      FILE       *fp,
  121.                        char       *txt_line,
  122.                  const Dmode_enum  mode));
  123. /*
  124. ************************************************** Defined in `gcal_utl.c'
  125. */
  126. IMPORT VOID_PTR
  127. my_malloc __P_((const int   amount,
  128.                 const int   exit_status,
  129.                 const char *module_name,
  130.                 const int   module_line,
  131.                 const char *var_name,
  132.                 const int   var_contents));
  133. IMPORT void
  134. my_error __P_((const int   exit_status,
  135.                const char *module_name,
  136.                const int   module_line,
  137.                const char *var_name,
  138.                const int   var_contents));
  139. IMPORT int
  140. asc_sort __P_((const char **a,
  141.                const char **b));
  142. IMPORT int
  143. des_sort __P_((const char **a,
  144.                const char **b));
  145. IMPORT Bool
  146. is_presorted __P_((char **table,
  147.                    int   elems));
  148. IMPORT void
  149. resort __P_((      char **table,
  150.              const int    elems));
  151. #if !USE_GER
  152. IMPORT const char *
  153. day_suffix __P_((int day));
  154. IMPORT const char *
  155. short3_day_name __P_((const int day));
  156. #endif
  157. IMPORT const char *
  158. short_day_name __P_((const int day));
  159. IMPORT const char *
  160. short_month_name __P_((const int month));
  161. IMPORT Bool
  162. jdate2sdate __P_((      int  jdate,
  163.                   const int  is_leap_year,
  164.                         int *day,
  165.                         int *month));
  166. IMPORT int
  167. weekday_of_date __P_((const int day,
  168.                       const int month,
  169.                       const int year));
  170. IMPORT int
  171. day_of_year __P_((const int day,
  172.                   const int month,
  173.                   const int year));
  174. IMPORT int
  175. days_of_february __P_((const int year));
  176. IMPORT int
  177. week_number __P_((const int day,
  178.                   const int month,
  179.                   const int year));
  180. IMPORT int
  181. weekno2jday __P_((      int week,
  182.                   const int year));
  183. /*
  184. ************************************************** Defined in `gcal_rcu.c'
  185. */
  186. EXPORT void
  187. rc_use __P_((void));
  188. #  if __cplusplus
  189. }
  190. #  endif
  191.  
  192.  
  193.  
  194. /*
  195. *  Declare public(extern) variables
  196. */
  197. IMPORT Hls_struct   ehls1s;                   /* Effective hls 1 start (current day) */
  198. IMPORT Hls_struct   ehls1e;                   /* Effective hls 1 end (current day) */
  199. IMPORT Hls_struct   ehls2s;                   /* Effective hls 2 start (holiday) */
  200. IMPORT Hls_struct   ehls2e;                   /* Effective hls 2 end (holiday) */
  201. #if HAVE_ASSERT_H
  202. IMPORT Uint         testval;                  /* Set to INT_MAX for checking the maximum table range */
  203. #endif
  204. IMPORT int          len_year_max;             /* String length of the maximum year able to compute */
  205. IMPORT int          start_day;                /* -s<0,1...7|day name> */
  206. IMPORT int          warning_level;            /* --debug[=0...WARN_LVL_MAX] */
  207. IMPORT int          day;                      /* Current day */
  208. IMPORT int          month;                    /* Current month */
  209. IMPORT int          year;                     /* Current year */
  210. IMPORT int          act_day;                  /* Actual day */
  211. IMPORT int          act_month;                /* Actual month */
  212. IMPORT int          act_year;                 /* Actual year */
  213. IMPORT int          fiscal_month;             /* Starting month of a fiscal year */
  214. IMPORT int          is_leap_year;             /* Is current year a leap year? */
  215. IMPORT int          holiday_vector[MONTH_MAX][MONTH_MAX]; /* Stores the holiday dates */
  216. IMPORT char         s[MAXLEN+1];              /* General purpose text buffer */
  217. IMPORT char         s2[MAXLEN+1];             /* General purpose text buffer */
  218. IMPORT char         s3[MAXLEN+1];             /* General purpose text buffer */
  219. IMPORT Bool         emu_hls;                  /* Must we emulate the highlighting sequences? */
  220. IMPORT char        *hd_table[HD_ELEMS_MAX];   /* Stores the eternal holiday list texts */
  221. IMPORT Bool         cal_julian_flag;          /* -j */
  222. IMPORT Bool         holiday_flag;             /* -n|N */
  223.  
  224.  
  225.  
  226. /*
  227.    Define public(extern) variables
  228. */
  229. PUBLIC Dvar_struct  rc_dvar[RC_DVAR_MAX];       /* Date variables a[=mmdd]...z[] (`yyyy'@{a|b|...|z}[[-]<n>]) */
  230. PUBLIC int          rc_period;                  /* Amount of period of fixed date warnings */
  231. PUBLIC int          rc_elems_max=RC_ELEMS_MAX;  /* Actual size of `rc_table' */
  232. PUBLIC int          rc_elems;                   /* Amount of resource file entries */
  233. PUBLIC int          rc_have_today_in_list=0;    /* [-c]d */
  234. PUBLIC int          len_fil_wt;                 /* Filler length of week number text */
  235. PUBLIC char       **rc_table=(char **)NULL;     /* Stores the valid fixed date texts */
  236. PUBLIC char        *rc_adate=(char *)NULL;      /* Text of modified actual date %... */
  237. PUBLIC char        *rc_filename=(char *)NULL;   /* Name of alternative resource file(s) -f|F<NAME[+...]> */
  238. PUBLIC char        *rc_grp_sep=(char *)NULL;    /* Fixed date list grouping separator [-c]g[txt] */
  239. PUBLIC Bool         rc_julian_flag=FALSE;       /* -jc */
  240. PUBLIC Bool         rc_both_dates_flag=FALSE;   /* -jcb */
  241. PUBLIC Bool         rc_use_flag=FALSE;          /* -c */
  242. PUBLIC Bool         rc_all_dates_flag=FALSE;    /* -C[] or -C[][T|W|M|Y] or -c[][T|W|M|Y] or -F<> */
  243. PUBLIC Bool         rc_sort_des_flag=FALSE;     /* [-c]- */
  244. PUBLIC Bool         rc_enable_fn_flag=FALSE;    /* [-c]a */
  245. PUBLIC Bool         rc_enable_hda_flag=FALSE;   /* [-c]e */
  246. PUBLIC Bool         rc_enable_hdl_flag=FALSE;   /* [-c]E */
  247. PUBLIC Bool         rc_weekno_flag=FALSE;       /* [-c]k */
  248. PUBLIC Bool         rc_period_list=FALSE;       /* [-c]l */
  249. PUBLIC Bool         rc_omit_date_flag=FALSE;    /* [-c]o */
  250. PUBLIC Bool         rc_title_flag=TRUE;         /* [-c]x */
  251. PUBLIC Bool         rc_count_flag=FALSE;        /* [-c]z */
  252. PUBLIC Bool         rc_period_flag=FALSE;       /* [-c]<<<<n>>[<d|w|+|-]>|`mmdd'|`mmww[w]'<n>> */
  253. PUBLIC Bool         rc_tomorrow_flag=FALSE;     /* [-c]t */
  254. PUBLIC Bool         rc_week_flag=FALSE;         /* [-c]w */
  255. PUBLIC Bool         rc_month_flag=FALSE;        /* [-c]m */
  256. PUBLIC Bool         rc_year_flag=FALSE;         /* [-c]y */
  257. PUBLIC Bool         rc_week_year_flag=FALSE;    /* [-c<<n>>]w */
  258. PUBLIC Bool         rc_forwards_flag=FALSE;     /* [-c<<n>|w|m|y>]+ */
  259. PUBLIC Bool         rc_backwards_flag=FALSE;    /* [-c<<n>|w|m|y>]- */
  260. PUBLIC Bool         rc_nzero_ldvar_flag=FALSE;  /* --hidden   don't reset local date variables */
  261. PUBLIC Bool         is_date_given=FALSE;        /* Is a date given in the command line? */
  262. PUBLIC Bool         is_1month_mode;             /* [-c]<n>w and complete week is in month */
  263. PUBLIC Bool         is_2month_mode;             /* [-c]<n>w and only part of week is in month */
  264. PUBLIC Bool         adate_set=FALSE;            /* [-c]<n>w and actual date modified */
  265.  
  266.  
  267.  
  268. #  ifdef ANSI_PROTO
  269. PUBLIC void
  270. rc_use (void)
  271. #  else /* !ANSI_PROTO */
  272.    PUBLIC void
  273. rc_use ()
  274. #  endif /* !ANSI_PROTO */
  275. /*
  276.    Processes a standard-/special resource file and displays the valid
  277.    fixed dates found resp.,  displays valid fixed dates of eternal holiday list
  278. */
  279. {
  280.    auto     FILE  *fp=(FILE *)NULL;
  281.    auto     FILE  *fp2=(FILE *)NULL;
  282.    register int    wd=weekday_of_date (act_day, act_month, act_year);
  283.    register int    ed;
  284.    register int    len;
  285.    register int    i;
  286.    register int    j;
  287.    register int    tmp_month=month;
  288.    register int    tmp_fiscal_month=fiscal_month;
  289.    register int    tmp_start_day=start_day;
  290.    register int    tmp_ad=act_day;
  291.    register int    tmp_am=act_month;
  292.    register int    tmp_ay=act_year;
  293.    auto     int    line=0;
  294.    auto     int    line2;
  295.    auto     int    i_dummy;
  296.    static   char   line_buffer[MAXLEN+1];
  297.    static   char   string[MAXLEN+1];
  298.    static   char   str[MAXLEN+1];
  299.    auto     char  *ptr_char;
  300.    auto     char   c_dummy;
  301. #if HAVE_ASSERT_H
  302.    static   Bool   rc_table_range_checked=FALSE;
  303. #endif
  304.    static   Bool   rc_table_initialized=FALSE;
  305.    auto     Bool   ok=FALSE;
  306.    auto     Bool   is_include;
  307.    auto     Bool   is_dvar;
  308.    auto     Bool   b_dummy;
  309.  
  310.  
  311. #if HAVE_ASSERT_H
  312.    /*
  313.       Check if value for maximum number of table entries
  314.         fits to the positive range of a signed int!!
  315.    */
  316.    if (!rc_table_range_checked)
  317.     {
  318.       assert(rc_elems_max>0);
  319.       assert((Uint)rc_elems_max<=testval);
  320.       rc_table_range_checked = TRUE;
  321.     }
  322. #endif
  323.    /*
  324.       Initial memory allocation for `rc_table[]'
  325.    */
  326.    if (!rc_table_initialized)
  327.     {
  328.       rc_table = (char **)my_malloc (RC_ELEMS_MAX*sizeof(char *),
  329.                                      124, __FILE__, __LINE__ -1,
  330.                                      "rc_elems", RC_ELEMS_MAX);
  331.       rc_table_initialized = TRUE;
  332.     }
  333.    /*
  334.       Initialize some important module global variables
  335.    */
  336.    len_fil_wt=rc_elems = 0;
  337.    /*
  338.       Depending on fixed date mode,
  339.         compute last valid day `ed' a fixed date may occur
  340.    */
  341.    ed=day = day_of_year (act_day, act_month, act_year);
  342.    if (is_date_given)
  343.     {
  344.       /*
  345.          NOT in simple month-/year mode (an explicit date is given in command line):
  346.            compute the starting- and ending loop values of requested period
  347.       */
  348.       ed = DAY_LAST + is_leap_year + 1;
  349.       if (!month)
  350.         day = DAY_MIN;
  351.       else
  352.        {
  353.          day = day_of_year (DAY_MIN, month, year);
  354.          if (month < MONTH_MAX)
  355.            ed = day_of_year (DAY_MIN, month+1, year);
  356.        }
  357.       /*
  358.          Then clean all flags, which are related to the fixed date warning period
  359.       */
  360.       rc_clean_flags ();
  361.     }
  362.    else
  363.     {
  364.       auto Bool  swap_flag=FALSE;
  365.  
  366.  
  367.       if (rc_tomorrow_flag)
  368.        {
  369.          /*
  370.             [-c]t modifier found
  371.          */
  372.          rc_period_list = FALSE;
  373.          ed += 2;
  374.        }
  375.       else
  376.         if (rc_week_flag)
  377.          {
  378.            /*
  379.               [-c]w[+|-] modifier found
  380.            */
  381.            rc_period_list = FALSE;
  382.            if (   !rc_forwards_flag
  383.                && !rc_backwards_flag)
  384.              day += (-DAY_MAX + SDAY(DAY_MAX-wd+1, start_day));
  385.            else
  386.             {
  387.               if (rc_forwards_flag)
  388.                {
  389.                  if (!rc_have_today_in_list)
  390.                    day++;
  391.                }
  392.               else
  393.                 day += rc_have_today_in_list;
  394.             }
  395.            if (   rc_backwards_flag
  396.                || (   !rc_forwards_flag
  397.                    && !rc_backwards_flag
  398.                    && (start_day > wd)))
  399.             {
  400.               swap_flag = TRUE;
  401.               ed -= DAY_MAX;
  402.             }
  403.            ed += SDAY(DAY_MAX-wd+1, start_day);
  404.          }
  405.         else
  406.           if (rc_month_flag)
  407.            {
  408.              /*
  409.                 [-c]m[+|-] modifier found
  410.              */
  411.              rc_period_list = FALSE;
  412.              if (   !rc_forwards_flag
  413.                  && !rc_backwards_flag)
  414.                day = day_of_year (DAY_MIN, act_month, act_year);
  415.              else
  416.               {
  417.                 if (rc_forwards_flag)
  418.                  {
  419.                    if (!rc_have_today_in_list)
  420.                      day++;
  421.                  }
  422.                 else
  423.                   day += rc_have_today_in_list;
  424.               }
  425.              if (rc_backwards_flag)
  426.                ed = day_of_year (DAY_MIN, act_month, act_year);
  427.              else
  428.               {
  429.                 if (act_month < MONTH_MAX)
  430.                   ed = day_of_year (DAY_MIN, act_month+1, act_year);
  431.                 else
  432.                   ed = DAY_LAST + is_leap_year + 1;
  433.               }
  434.            }
  435.           else
  436.             if (rc_year_flag)
  437.              {
  438.                /*
  439.                   [-c]y[+|-] modifier found
  440.                */
  441.                rc_period_list = FALSE;
  442.                if (   !rc_forwards_flag
  443.                    && !rc_backwards_flag)
  444.                  day = DAY_MIN;
  445.                else
  446.                 {
  447.                   if (rc_forwards_flag)
  448.                    {
  449.                      if (!rc_have_today_in_list)
  450.                        day++;
  451.                    }
  452.                   else
  453.                     day += rc_have_today_in_list;
  454.                 }
  455.                if (rc_backwards_flag)
  456.                  ed = DAY_MIN;
  457.                else
  458.                  ed = DAY_LAST + is_leap_year + 1;
  459.              }
  460.             else
  461.               if (rc_period_flag)
  462.                {
  463.                  if (rc_week_year_flag)
  464.                   {
  465.                     /*
  466.                        [-c]<n>w flag found
  467.                          (those ISO-8601:1988 weeks start at monday)
  468.                     */
  469.                     wd=start_day = 1;
  470.                     /*
  471.                        Compute day number of year the week start at
  472.                     */
  473.                     j=day = weekno2jday (rc_period, act_year);
  474.                     if (day != -WEEK_MAX)
  475.                      {
  476.                        if (rc_period_list)
  477.                         {
  478.                           /*
  479.                              [-c]<n>w modifier found
  480.                           */
  481.                           if (day > ed)
  482.                            {
  483.                              if (day < DAY_LAST+is_leap_year)
  484.                               {
  485.                                 rc_forwards_flag = TRUE;
  486.                                 day = ed + 1 - rc_have_today_in_list;
  487.                                 ed = j + DAY_MAX;
  488.                                 if (ed > DAY_LAST+is_leap_year+1)
  489.                                   ed = DAY_LAST + is_leap_year + 1;
  490.                               }
  491.                              else
  492.                                /*
  493.                                   No fixed date messages to display
  494.                                */
  495.                                day = ed;
  496.                            }
  497.                           else
  498.                            {
  499.                              if (ed > DAY_MIN)
  500.                               {
  501.                                 rc_backwards_flag = TRUE;
  502.                                 day = ed + rc_have_today_in_list;
  503.                                 ed = j;
  504.                                 if (ed < DAY_MIN)
  505.                                   ed = DAY_MIN;
  506.                               }
  507.                              else
  508.                                /*
  509.                                   No fixed date messages to display
  510.                                */
  511.                                day = ed;
  512.                            }
  513.                         }
  514.                        else
  515.                         {
  516.                           /*
  517.                              [-c]<n>w modifier found:
  518.                                set actual date to monday's date of week
  519.                                and omit highlighting that date; boolean
  520.                                `adate_set' is set to distinct this
  521.                                SPECIAL mode from other modes...
  522.                           */
  523.                           rc_week_flag = TRUE;
  524.                           ed = day + DAY_MAX;
  525.                           if (day < DAY_MIN)
  526.                            {
  527.                              act_year--;
  528.                              j += (DAY_LAST + (days_of_february (act_year) == 29));
  529.                            }
  530.                           else
  531.                             j = day;
  532.                           (void)jdate2sdate (j, is_leap_year, &act_day, &act_month);
  533.                           month = act_month;
  534.                           fiscal_month = MONTH_MIN;
  535.                           adate_set = TRUE;
  536.                         }
  537.                      }
  538.                     else
  539.                       /*
  540.                          Wanted week doesn't exist:
  541.                            don't display any fixed date messages
  542.                       */
  543.                       day = ed;
  544.                   }
  545.                  else
  546.                    /*
  547.                       [-c]<n>d,
  548.                       [-c]`mmdd',
  549.                       [-c]`mmww[w]'<n>,
  550.                       [-c]*d|w<n>[`ww[w]'] and
  551.                       [-c]@<e|`dvar'>[[-]<n>]
  552.                         modifiers are managed in this subsection too
  553.                    */
  554.                    if (   rc_forwards_flag
  555.                        && (day < DAY_LAST+is_leap_year))
  556.                     {
  557.                       if (rc_period_list)
  558.                        {
  559.                          /*
  560.                             [-c]<n>+ modifier found
  561.                          */
  562.                          if (!rc_have_today_in_list)
  563.                            day++;
  564.                          ed += (rc_period + 1);
  565.                          if (ed > DAY_LAST+is_leap_year+1)
  566.                            ed = DAY_LAST + is_leap_year + 1;
  567.                        }
  568.                       else
  569.                        {
  570.                          /*
  571.                             [-c]<n>+ modifier found
  572.                          */
  573.                          rc_forwards_flag = FALSE;
  574.                          day += rc_period;
  575.                          ed = day;
  576.                          if (day < DAY_LAST+is_leap_year+1)
  577.                           {
  578.                             rc_period_flag = FALSE;
  579.                             (void)jdate2sdate (day, is_leap_year, &act_day, &act_month);
  580.                             month = act_month;
  581.                             ed++;
  582.                           }
  583.                        }
  584.                     }
  585.                    else
  586.                      if (   rc_backwards_flag
  587.                          && (day > DAY_MIN))
  588.                       {
  589.                         if (rc_period_list)
  590.                          {
  591.                            /*
  592.                               [-c]<n>- modifier found
  593.                            */
  594.                            day += rc_have_today_in_list;
  595.                            ed -= rc_period;
  596.                            if (ed < DAY_MIN)
  597.                              ed = DAY_MIN;
  598.                          }
  599.                         else
  600.                          {
  601.                            /*
  602.                               [-c]<n>- modifier found
  603.                            */
  604.                            rc_backwards_flag = FALSE;
  605.                            day -= rc_period;
  606.                            ed = day;
  607.                            if (day > 0)
  608.                             {
  609.                               rc_period_flag = FALSE;
  610.                               (void)jdate2sdate (day, is_leap_year, &act_day, &act_month);
  611.                               month = act_month;
  612.                               ed++;
  613.                             }
  614.                          }
  615.                       }
  616.                }
  617.               else
  618.                {
  619.                  /*
  620.                     Only simple -c (without any modifiers) found
  621.                  */
  622.                  rc_period_list = FALSE;
  623.                  ed++;
  624.                }
  625.       /*
  626.          Swap start date `day' and ending date `ed' of period
  627.       */
  628.       if (   swap_flag
  629.           || rc_backwards_flag)
  630.         day ^= (ed ^= (day ^= ed));
  631.     }
  632.    if (day != ed)
  633.     {
  634.       /*
  635.          Now include the eternal holidays, which are valid fixed dates,
  636.            into `*rc_table[]'
  637.       */
  638.       if (   rc_enable_hda_flag
  639.           || rc_enable_hdl_flag)
  640.        {
  641.          while (   (hd_table[line] != (char *)NULL)
  642.                 && (line < HD_ELEMS_MAX))
  643.           {
  644.             strcpy(line_buffer, hd_table[line]);
  645.             i = LEN_HD_NAME + len_year_max + 4 + 2;
  646.             if (   rc_enable_hda_flag
  647.                 || (   rc_enable_hdl_flag
  648.                     && (line_buffer[i] != *DIS_HLS_PREF)))
  649.              {
  650.                i -= 2;
  651.                while (   i
  652.                       && MY_ISSPACE(line_buffer[i]))
  653.                  line_buffer[i--] = '\0';
  654.                if (i > len_year_max+4)
  655.                  rc_check (line_buffer, "`"HD_LIST_TITLE"'", &line, &rc_elems, day, ed, wd);
  656.              }
  657.             if (!holiday_flag)
  658.              {
  659.                free(hd_table[line]);
  660.                hd_table[line] = (char *)NULL;
  661.              }
  662.             line++;
  663.           }
  664.          /*
  665.             If fixed date warning mode is related to a week or to tomorrow
  666.               and the warning period is off the current year, include those
  667.               eternal holidays in year +/- 1 into `rc_table', which are
  668.               valid fixed dates
  669.          */
  670.          if (   (   rc_tomorrow_flag
  671.                  || rc_week_flag)
  672.              && !is_date_given
  673.              && !is_1month_mode
  674.              && !is_2month_mode
  675.              && (   (   !rc_forwards_flag
  676.                      && !rc_backwards_flag
  677.                      && (   (   (year+1 <= YEAR_MAX)
  678.                              && (ed > DAY_LAST+is_leap_year+1))
  679.                          || (   (year-1 >= YEAR_MIN)
  680.                              && (day < DAY_MIN))))
  681.                  || (   rc_forwards_flag
  682.                      && (   (year+1 <= YEAR_MAX)
  683.                          && (ed > DAY_LAST+is_leap_year+1)))
  684.                  || (   rc_backwards_flag
  685.                      && (   (year-1 >= YEAR_MIN)
  686.                          && (day < DAY_MIN)))))
  687.           {
  688.             register int  jtmp_ad=act_day;
  689.             register int  tay=act_year;
  690.             register int  tam=act_month;
  691.             register int  tad=act_day;
  692.  
  693.  
  694.             if (holiday_flag)
  695.               for (i=0 ; i < line ; i++)
  696.                {
  697.                  free(hd_table[i]);
  698.                  hd_table[i] = (char *)NULL;
  699.                }
  700.             line = 0;
  701.             if (day < DAY_MIN)
  702.              {
  703.                year--;
  704.                month = MONTH_MAX;
  705.              }
  706.             else
  707.              {
  708.                year++;
  709.                month = MONTH_MIN;
  710.              }
  711.             is_leap_year = (days_of_february (year) == 29);
  712.             if (cal_julian_flag)
  713.               act_day = day_of_year (jtmp_ad, act_month, act_year);
  714.             if (adate_set)
  715.               fiscal_month = tmp_fiscal_month;
  716.             if (   (   (year == EASTER_MIN-1)
  717.                     && (fiscal_month > MONTH_MIN))
  718.                 || (   (year >= EASTER_MIN)
  719.                     && (year <= EASTER_MAX)))
  720.               print_all_holidays (TRUE, TRUE);
  721.             if (adate_set)
  722.               fiscal_month = MONTH_MIN;
  723.             if (day < DAY_MIN)
  724.              {
  725.                year++;
  726.                month = MONTH_MIN;
  727.              }
  728.             else
  729.              {
  730.                year--;
  731.                month = MONTH_MAX;
  732.              }
  733.             while (   (hd_table[line] != (char *)NULL)
  734.                    && (line < HD_ELEMS_MAX))
  735.              {
  736.                strcpy(line_buffer, hd_table[line]);
  737.                i = LEN_HD_NAME + len_year_max + 4 + 2;
  738.                if (   rc_enable_hda_flag
  739.                    || (   rc_enable_hdl_flag
  740.                        && (line_buffer[i] == *DIS_HLS_PREF)))
  741.                 {
  742.                   i -= 2;
  743.                   while (   i
  744.                          && MY_ISSPACE(line_buffer[i]))
  745.                     line_buffer[i--] = '\0';
  746.                   if (i > len_year_max+4)
  747.                     rc_check (line_buffer, "`"HD_LIST_TITLE"'", &line, &rc_elems, day, ed, wd);
  748.                 }
  749.                free(hd_table[line]);
  750.                hd_table[line] = (char *)NULL;
  751.                line++;
  752.              }
  753.             is_leap_year = (days_of_february (year) == 29);
  754.             if (adate_set)
  755.              {
  756.                fiscal_month = tmp_fiscal_month;
  757.                act_year = tmp_ay;
  758.                act_month = tmp_am;
  759.                jtmp_ad=act_day = tmp_ad;
  760.              }
  761.             if (cal_julian_flag)
  762.               act_day = day_of_year (jtmp_ad, act_month, act_year);
  763.             if (   holiday_flag
  764.                 && (   (   (year == EASTER_MIN-1)
  765.                         && (fiscal_month > MONTH_MIN))
  766.                     || (   (year >= EASTER_MIN)
  767.                         && (year <= EASTER_MAX))))
  768.               print_all_holidays (TRUE, TRUE);
  769.             if (cal_julian_flag)
  770.               act_day = jtmp_ad;
  771.             if (adate_set)
  772.              {
  773.                fiscal_month = MONTH_MIN;
  774.                act_year = tay;
  775.                month=act_month = tam;
  776.                act_day = tad;
  777.              }
  778.             else
  779.               month = tmp_month;
  780.           }
  781.        }
  782.       /*
  783.          Try to open the resource file(s)
  784.       */
  785.       if (rc_filename == (char *)NULL)
  786.         *s3 = '\0';
  787.       else
  788.        {
  789.          strncpy(s3, rc_filename, MAXLEN+1);
  790.          s3[MAXLEN] = '\0';
  791.        }
  792.       while (!ok)
  793.        {
  794.          if (*s3)
  795.           {
  796.             if (strchr(s3, *RC_FNAME_SEP) == (char *)NULL)
  797.              {
  798.                /*
  799.                   Single alternative resource file name given in command line
  800.                */
  801.                ok = TRUE;
  802.                strcpy(str, s3);
  803.                fp = file_open (str, REsource);
  804.              }
  805.             else
  806.              {
  807.                auto char  *ptr2_char;
  808.                auto Bool   ok2=FALSE;
  809.  
  810.  
  811.                /*
  812.                   List of alternative resource file names given in command line
  813.                */
  814.                while (   !ok2
  815.                       && (fp == (FILE *)NULL))
  816.                 {
  817.                   ok2 = (Bool)((ptr2_char=strchr(s3, *RC_FNAME_SEP)) == (char *)NULL);
  818.  
  819.                   if (ok2)
  820.                     i = (int)strlen(s3);
  821.                   else
  822.                     i = (int)strlen(s3) - strlen(ptr2_char);
  823.                   strcpy(str, s3);
  824.                   str[i] = '\0';
  825.                   if (*str)
  826.                     fp = file_open (str, REsource);
  827.                   if (ok2)
  828.                    {
  829.                      if (!s3[i])
  830.                        ok = TRUE;
  831.                      break;
  832.                    }
  833.                   ptr2_char = s3 + i + 1;
  834.                   strcpy(s3, ptr2_char);
  835.                   if (!*s3)
  836.                     ok=ok2 = TRUE;
  837.                 }
  838.              }
  839.           }
  840.          if (   !ok
  841.              && (fp == (FILE *)NULL))
  842.           {
  843.             /*
  844.                Use standard resource file, always processed at last
  845.             */
  846.             ok = TRUE;
  847.             strcpy(str, PRGR_RC_NAME);
  848.             fp = file_open (str, REsource);
  849.           }
  850.          /*
  851.             Now read and check contents of a resource file `str'
  852.               and include valid fixed dates into `*rc_table[]'
  853.          */
  854.          if (fp != (FILE *)NULL)
  855.           {
  856.             auto int    in_pool=0;
  857.             auto char  *pool=(char *)NULL;
  858.             auto char  *ptr_pool=(char *)NULL;
  859.  
  860.  
  861.             pool = (char *)my_malloc (BUF_LEN+1, 124, __FILE__, __LINE__, "pool", 0);
  862.             /*
  863.                First copy the contents of global date variables
  864.                  to local variables (if one of these isn't defined)
  865.                  so we can perform local operations (++, --, +=, -=)
  866.                  on global variables
  867.             */
  868.             for (i=0 ; i < RC_DVAR_MAX ; i++)
  869.               if (   rc_dvar[i].g.month
  870.                   && !rc_dvar[i].l.month)
  871.                {
  872.                  rc_dvar[i].l.month = rc_dvar[i].g.month;
  873.                  rc_dvar[i].l.day = rc_dvar[i].g.day;
  874.                }
  875.             line = 0;
  876.             while ((ptr_pool=file_read_line (fp, line_buffer, &in_pool, pool, ptr_pool,
  877.                                              str, &line, REsource, &is_include, &is_dvar)) != (char *)NULL)
  878.              {
  879.                /*
  880.                   Check whether an "#include" statement is found
  881.                */
  882.                if (is_include)
  883.                 {
  884.                   auto Bool  is_usr_file=FALSE;
  885.                   auto Bool  is_sys_file=FALSE;
  886.  
  887.  
  888.                   len = (int)strlen(RC_INCL_STMENT);
  889.                   strcpy(string, line_buffer);
  890.                   for (i=0 ; i < len ; i++)
  891.                     string[i] = (char)tolower(string[i]);
  892.                   if (strncmp(string, RC_INCL_STMENT, len))
  893.                     /*
  894.                        Error, misspelled "#include" directive found
  895.                     */
  896.                     my_error (120, str, line, line_buffer, 0);
  897.                   /*
  898.                      Skip leading whitespace characters
  899.                   */
  900.                   while (MY_ISSPACE(string[i]))
  901.                     i++;
  902.                   if (   !string[i]
  903.                       || string[i] == '\n')
  904.                     /*
  905.                        Error, no include file "argument" encoded
  906.                     */
  907.                     my_error (120, str, line, line_buffer, 0);
  908.                   if (string[i] == *RC_INCL_USR_ID)
  909.                     is_usr_file = TRUE;
  910.                   else
  911.                     if (string[i] == *RC_INCL_SYS_ID)
  912.                       is_sys_file = TRUE;
  913.                     else
  914.                       /*
  915.                          Error, illegal leading include file name delimiter found
  916.                       */
  917.                       my_error (120, str, line, line_buffer, 0);
  918.                   i++;
  919.                   /*
  920.                      Skip leading whitespace characters before include file name
  921.                   */
  922.                   while (MY_ISSPACE(string[i]))
  923.                     i++;
  924.                   j = 0;
  925.                   /*
  926.                      Get include file name
  927.                   */
  928.                   while (   string[i]
  929.                          && !MY_ISSPACE(string[i])
  930.                          && (string[i] != *RC_INCL_USR_OD)
  931.                          && (string[i] != *RC_INCL_SYS_OD))
  932.                     string[j++] = string[i++];
  933.                   /*
  934.                      Skip trailing whitespace characters after include file name
  935.                   */
  936.                   while (MY_ISSPACE(string[i]))
  937.                     i++;
  938.                   if (   (   is_usr_file
  939.                           && (string[i] != *RC_INCL_USR_OD))
  940.                       || (   is_sys_file
  941.                           && (string[i] != *RC_INCL_SYS_OD)))
  942.                     /*
  943.                        Error, illegal trailing include file name delimiter found
  944.                     */
  945.                     my_error (120, str, line, line_buffer, 0);
  946.                   if (!j)
  947.                     /*
  948.                        Error, no include file "name" encoded
  949.                     */
  950.                     my_error (120, str, line, line_buffer, 0);
  951.                   /*
  952.                      Now we have the name of include file
  953.                        and the mode of operation
  954.                   */
  955.                   string[j] = '\0';
  956.                   /*
  957.                      Try to open include file
  958.                   */
  959.                   fp2 = file_open (string, (is_usr_file) ? USr_include : SYs_include);
  960.                   /*
  961.                      Include file does exist so read it in
  962.                   */
  963.                   if (fp2 != (FILE *)NULL)
  964.                    {
  965.                      auto Dvar_base_struct   tmp_dvars[RC_DVAR_MAX];
  966.                      auto int                in_2pool=0;
  967.                      auto char              *pool2=(char *)NULL;
  968.                      auto char              *ptr_2pool=(char *)NULL;
  969.  
  970.  
  971.                      pool2 = (char *)my_malloc (BUF_LEN+1, 124, __FILE__, __LINE__, "pool2", 0);
  972.                      /*
  973.                         Store all local date variables into `tmp_dvars[]'
  974.                      */
  975.                      for (i=0 ; i < RC_DVAR_MAX ; i++)
  976.                       {
  977.                         tmp_dvars[i].month = rc_dvar[i].l.month;
  978.                         tmp_dvars[i].day = rc_dvar[i].l.day;
  979.                       }
  980.                      line2 = 0;
  981.                      while ((ptr_2pool=file_read_line (fp2, line_buffer, &in_2pool, pool2, ptr_2pool,
  982.                                                        string, &line2, REsource, &is_include, &is_dvar))
  983.                                       != (char *)NULL)
  984.                        if (is_include)
  985.                          /*
  986.                             Error, invalid sub-include statement found
  987.                          */
  988.                          my_error (119, string, line2, line_buffer, 0);
  989.                        else
  990.                          if (   *line_buffer
  991.                              && !is_dvar)
  992.                            rc_check (line_buffer, string, &line2, &rc_elems, day, ed, wd);
  993.                      fclose(fp2);
  994.                      fp2 = (FILE *)NULL;
  995.                      free(pool2);
  996.                      /*
  997.                         Restore all local date variables from `tmp_dvars[]'
  998.                      */
  999.                      for (i=0 ; i < RC_DVAR_MAX ; i++)
  1000.                       {
  1001.                         rc_dvar[i].l.month = tmp_dvars[i].month;
  1002.                         rc_dvar[i].l.day = tmp_dvars[i].day;
  1003.                       }
  1004.                    }
  1005.                 }
  1006.                else
  1007.                  if (   *line_buffer
  1008.                      && !is_dvar)
  1009.                    rc_check (line_buffer, str, &line, &rc_elems, day, ed, wd);
  1010.              }
  1011.             fclose(fp);
  1012.             fp = (FILE *)NULL;
  1013.             free(pool);
  1014.             /*
  1015.                Next file -> reset all local date variables to 0,
  1016.                  if --hidden flag set, don't reset them !!
  1017.             */
  1018.             if (!rc_nzero_ldvar_flag)
  1019.               for (i=0 ; i < RC_DVAR_MAX ; i++)
  1020.                 rc_dvar[i].l.month = (char)0;
  1021.           }
  1022.        }
  1023.       fiscal_month = tmp_fiscal_month;
  1024.       /*
  1025.          Now display the valid resource file(s) entries in sorted order
  1026.       */
  1027.       if (   rc_elems
  1028.           || rc_all_dates_flag)
  1029.        {
  1030.          auto     int  d=0;
  1031.          auto     int  m=0;
  1032.          auto     int  y=0;
  1033.          auto     int  dd=0;
  1034.          auto     int  mm=0;
  1035.          auto     int  yy=0;
  1036.  
  1037.  
  1038.  
  1039.          len = (rc_julian_flag && !rc_both_dates_flag) ? 3 : 2;
  1040.          j = 0;
  1041.          /*
  1042.             If `rc_all_dates_flag' is set, complete the contents of `*rc_table[]',
  1043.               i.e., generate "empty" warnings for each day in requested period
  1044.          */
  1045.          if (rc_all_dates_flag)
  1046.           {
  1047.             register int  rc_e=rc_elems;
  1048.  
  1049.  
  1050.             /*
  1051.                Lets sort ascending first only in case `rc_table[]' isn't presorted!
  1052.             */
  1053.             if (   (rc_elems > 1)
  1054.                 && !is_presorted (rc_table, rc_elems))
  1055.               qsort((VOID_PTR)rc_table, rc_elems, sizeof *rc_table, (Func_cmp)asc_sort);
  1056.             if (rc_elems)
  1057.               (void)rc_get_date (rc_table[j], &b_dummy, &d, &m, &y, &i_dummy, &i_dummy,
  1058.                                  &c_dummy, &i_dummy, &i_dummy, str, line, rc_table[j], TRUE);
  1059.             for (i=day ; i < ed ; i++)
  1060.              {
  1061.                yy = year;
  1062.                ok = jdate2sdate (i, is_leap_year, &dd, &mm);
  1063.                if (!ok)
  1064.                 {
  1065.                   if (   rc_tomorrow_flag
  1066.                       || rc_week_flag)
  1067.                    {
  1068.                      if (i < DAY_MIN)
  1069.                       {
  1070.                         yy = year - 1;
  1071.                         if (yy < YEAR_MIN)
  1072.                           break;
  1073.                         line = (days_of_february (yy) == 29);
  1074.                         (void)jdate2sdate (DAY_LAST+line+i, line, &dd, &mm);
  1075.                       }
  1076.                      else
  1077.                        if (i > DAY_LAST+is_leap_year)
  1078.                         {
  1079.                           yy = year + 1;
  1080.                           if (yy > YEAR_MAX)
  1081.                             break;
  1082.                           line = (days_of_february (yy) == 29);
  1083.                           (void)jdate2sdate (i-(DAY_LAST+is_leap_year), line, &dd, &mm);
  1084.                         }
  1085.                    }
  1086.                   else
  1087.                     break;
  1088.                 }
  1089.                if (   j == rc_e
  1090.                    || mm < m
  1091.                    || yy < y
  1092.                    || (   (dd < d)
  1093.                        && (mm <= m)
  1094.                        && (yy <= y)))
  1095.                 {
  1096.                   sprintf(line_buffer, "%0*d%02d%02d ", len_year_max, yy, mm, dd);
  1097.                   rc_check (line_buffer, "`"RC_INTERNAL_TXT"'", &line, &rc_elems, day, ed, wd);
  1098.                 }
  1099.                else
  1100.                  while (   (dd == d)
  1101.                         && (mm == m)
  1102.                         && (yy == y))
  1103.                    if (j+1 < rc_e)
  1104.                     {
  1105.                       j++;
  1106.                       (void)rc_get_date (rc_table[j], &b_dummy, &d, &m, &y, &i_dummy, &i_dummy,
  1107.                                          &c_dummy, &i_dummy, &i_dummy, str, line, rc_table[j], TRUE);
  1108.                     }
  1109.                    else
  1110.                     {
  1111.                       j++;
  1112.                       break;
  1113.                     }
  1114.              }
  1115.             /*
  1116.                Respect fiscal year mode...
  1117.             */
  1118.             if (   (fiscal_month > MONTH_MIN)
  1119.                 && (year < YEAR_MAX))
  1120.              {
  1121.                day = DAY_MIN;
  1122.                yy = year + 1;
  1123.                is_leap_year = (days_of_february (yy) == 29);
  1124.                if (fiscal_month < MONTH_MAX)
  1125.                  ed = day_of_year (DAY_MIN, fiscal_month+1, yy) + 1;
  1126.                else
  1127.                  ed = DAY_LAST + is_leap_year + 1;
  1128.                for (i=day ; i < ed ; i++)
  1129.                 {
  1130.                   ok = jdate2sdate (i, is_leap_year, &dd, &mm);
  1131.                   if (!ok)
  1132.                     break;
  1133.                   if (   j == rc_e
  1134.                       || mm < m
  1135.                       || yy < y
  1136.                       || (   (dd < d)
  1137.                           && (mm <= m)
  1138.                           && (yy <= y)))
  1139.                    {
  1140.                      sprintf(line_buffer, "%0*d%02d%02d ", len_year_max, yy, mm, dd);
  1141.                      rc_check (line_buffer, "`"RC_INTERNAL_TXT"'", &line, &rc_elems, day, ed, wd);
  1142.                    }
  1143.                   else
  1144.                     while (   (dd == d)
  1145.                            && (mm == m)
  1146.                            && (yy == y))
  1147.                       if (j+1 < rc_e)
  1148.                        {
  1149.                          j++;
  1150.                          (void)rc_get_date (rc_table[j], &b_dummy, &d, &m, &y, &i_dummy, &i_dummy,
  1151.                                             &c_dummy, &i_dummy, &i_dummy, str, line, rc_table[j], TRUE);
  1152.                        }
  1153.                       else
  1154.                        {
  1155.                          j++;
  1156.                          break;
  1157.                        }
  1158.                 }
  1159.              }
  1160.             is_leap_year = (days_of_february (year) == 29);
  1161.           }
  1162.          if (rc_elems)
  1163.           {
  1164.             register int   hls1_len=(ehls1s.len!=1) ? ehls1s.len+ehls1e.len : 0;
  1165.             register int   hls2_len=(ehls1s.len!=1) ? ehls2s.len+ehls2e.len : 0;
  1166.             register int   skip=0;
  1167.             register int   len_rce=0;
  1168.             register int   len_fn_part;
  1169.             register int   len_s;
  1170.             register int   len_ptr_char;
  1171.             auto     Bool  same_date=FALSE;
  1172.             auto     Bool  hls1_set;
  1173.             auto     Bool  hls2_set;
  1174.  
  1175.  
  1176.             /*
  1177.                At last, sort the fixed date warnings only if they are not presorted
  1178.             */
  1179.             if (rc_elems > 1)
  1180.              {
  1181.                if (!is_presorted (rc_table, rc_elems))
  1182.                 {
  1183.                   if (rc_sort_des_flag)
  1184.                     qsort((VOID_PTR)rc_table, rc_elems, sizeof *rc_table, (Func_cmp)des_sort);
  1185.                   else
  1186.                     qsort((VOID_PTR)rc_table, rc_elems, sizeof *rc_table, (Func_cmp)asc_sort);
  1187.                 }
  1188.                else
  1189.                  if (rc_sort_des_flag)
  1190.                    /*
  1191.                       `rc_table[]' is presorted and must be shown in descending sort order,
  1192.                         rearrange its internal sort order from ascending to descending sort order.
  1193.                    */
  1194.                    resort (rc_table, rc_elems);
  1195.              }
  1196.             /*
  1197.                Copy `rc_grp_sep' [-c]g[] to text buffer variable `s3' for further use
  1198.                  and perform the `~'-TILDE expansion
  1199.             */
  1200.             if (rc_grp_sep != (char *)NULL)
  1201.              {
  1202.                strncpy(s3, rc_grp_sep, MAXLEN+1);
  1203.                s3[MAXLEN] = '\0';
  1204.                ptr_char = s3;
  1205.                if (*ptr_char)
  1206.                  if (strchr(ptr_char, RC_NL_CHAR) != (char *)NULL)
  1207.                   {
  1208.                     /*
  1209.                        `~'-TILDE or quoted `\~'-TILDE found in group separator `txt':
  1210.                          quote TILDE resp., insert a real `\n'-NEWLINE character
  1211.                     */
  1212.                     i = 0;
  1213.                     while (*ptr_char)
  1214.                      {
  1215.                        if (*ptr_char == RC_NL_CHAR)
  1216.                         {
  1217.                           if (i)
  1218.                            {
  1219.                              /*
  1220.                                 RC_NL_CHAR is single `\~' quoted
  1221.                                            or double `\\~' quoted:
  1222.                                   replace QUOTE_CHAR by RC_NL_CHAR resp.,
  1223.                                   replace last QUOTE_CHAR by RC_NL_CHAR
  1224.                              */
  1225.                              if (s3[i-1] == QUOTE_CHAR)
  1226.                                s3[i-1] = *ptr_char;
  1227.                              else
  1228.                                /*
  1229.                                   RC_NL_CHAR is not quoted `~':
  1230.                                     insert a real `\n'-NEWLINE character
  1231.                                */
  1232.                                s3[i++] = '\n';
  1233.                            }
  1234.                           else
  1235.                             /*
  1236.                                RC_NL_CHAR is not quoted `~':
  1237.                                  insert a real `\n'-NEWLINE character
  1238.                             */
  1239.                             s3[i++] = '\n';
  1240.                         }
  1241.                        else
  1242.                          s3[i++] = *ptr_char;
  1243.                        ptr_char++;
  1244.                      }
  1245.                     s3[i] = '\0';
  1246.                   }
  1247.              }
  1248.             /*
  1249.                Now display a leading newline before text/title
  1250.             */
  1251.             *s = '\0';
  1252.             print_text (stdout, s, INternal);
  1253.             /*
  1254.                Now display a leading text/title
  1255.             */
  1256.             if (rc_title_flag)
  1257.              {
  1258.                sprintf(s, "%s:", RC_LIST_TITLE);
  1259.                print_text (stdout, s, INternal);
  1260.                print_text (stdout, s, INternal);
  1261.              }
  1262.             /*
  1263.                Detect the actual length of `rc_elems'
  1264.             */
  1265.             sprintf(s, "%d", rc_elems);
  1266.             len_rce = (int)strlen(s) + 3;   /* +3 because of the ")  " text */
  1267.             /*
  1268.                Display all fixed date warnings in `rc_table[]'
  1269.             */
  1270.             for (line=0 ; line < rc_elems ; line++)
  1271.              {
  1272.                ptr_char = rc_get_date (rc_table[line], &b_dummy, &day, &m, &y, &i_dummy, &i_dummy,
  1273.                                        &c_dummy, &i_dummy, &i_dummy, str, line, rc_table[j], TRUE);
  1274.                if (   !line
  1275.                    && (   rc_omit_date_flag
  1276.                        || rc_grp_sep != (char *)NULL))
  1277.                 {
  1278.                   dd = day;
  1279.                   mm = m;
  1280.                   yy = y;
  1281.                 }
  1282.                /*
  1283.                   Avoid displaying of duplicate resource file entries
  1284.                */
  1285.                if (   !line
  1286.                    || (   line
  1287.                        && strcmp(line_buffer, rc_table[line])))
  1288.                 {
  1289.                   strcpy(line_buffer, rc_table[line]);
  1290.                   /*
  1291.                      Now display fixed date warning list group separator resp.,
  1292.                        detect if date of warning differs from previous warning
  1293.                   */
  1294.                   if (   rc_omit_date_flag
  1295.                       || rc_grp_sep != (char *)NULL)
  1296.                    {
  1297.                      if (   (day == dd)
  1298.                          && (m == mm)
  1299.                          && (y == yy))
  1300.                       {
  1301.                         /*
  1302.                            Same date:
  1303.                              avoid displaying of group separator
  1304.                         */
  1305.                         if (line)
  1306.                           same_date = TRUE;
  1307.                       }
  1308.                      else
  1309.                       {
  1310.                         /*
  1311.                            Date differs
  1312.                         */
  1313.                         same_date = FALSE;
  1314.                         dd = day;
  1315.                         mm = m;
  1316.                         yy = y;
  1317.                         if (rc_grp_sep != (char *)NULL)
  1318.                          {
  1319.                            /*
  1320.                               Display constructed group separator `txt' [-c]g[]
  1321.                            */
  1322.                            strcpy(s, s3);
  1323.                            print_text (stdout, s, INternal);
  1324.                          }
  1325.                       }
  1326.                    }
  1327.                   /*
  1328.                      Display leading (highlighted)date of fixed date text
  1329.                   */
  1330.                   if (rc_weekno_flag)
  1331.                    {
  1332.                      j = week_number (day, m, y);
  1333.                      if (!j)
  1334.                       {
  1335.                         /*
  1336.                            Week is both last week of previous year and first week of year
  1337.                         */
  1338.                         if (y == GREG_YEAR+1)
  1339.                           j = ((DAY_LAST + (days_of_february (GREG_YEAR) == 29)
  1340.                               - (GREG_L_DAY - GREG_F_DAY + 1)) / DAY_MAX) + 1;
  1341.                         else
  1342.                           j = WEEK_MAX + 1;
  1343.                         sprintf(s2, "%02d/1", j);
  1344.                         if (rc_count_flag)
  1345. #  if USE_GER
  1346.                           sprintf(s, "%0*d)  |%s| %s, ", len_rce-3, (line-skip)+1, s2,
  1347.                                   short_day_name (weekday_of_date (day, m, y)));
  1348. #  else /* !USE_GER */
  1349.                           sprintf(s, "%0*d)  |%s| %s, ", len_rce-3, (line-skip)+1, s2,
  1350.                                   short3_day_name (weekday_of_date (day, m, y)));
  1351. #  endif /* !USE_GER */
  1352.                         else
  1353. #  if USE_GER
  1354.                           sprintf(s, "|%s| %s, ", s2,
  1355.                                   short_day_name (weekday_of_date (day, m, y)));
  1356. #  else /* !USE_GER */
  1357.                           sprintf(s, "|%s| %s, ", s2,
  1358.                                   short3_day_name (weekday_of_date (day, m, y)));
  1359. #  endif /* !USE_GER */
  1360.                       }
  1361.                      else
  1362.                       {
  1363.                         /*
  1364.                            Ordinary week 1...52|53
  1365.                         */
  1366.                         if (rc_count_flag)
  1367. #  if USE_GER
  1368.                           sprintf(s, "%0*d)  |%02d|%*s %s, ", len_rce-3, (line-skip)+1, j,
  1369.                                   len_fil_wt, "", short_day_name (weekday_of_date (day, m, y)));
  1370. #  else /* !USE_GER */
  1371.                           sprintf(s, "%0*d)  |%02d|%*s %s, ", len_rce-3, (line-skip)+1, j,
  1372.                                   len_fil_wt, "", short3_day_name (weekday_of_date (day, m, y)));
  1373. #  endif /* !USE_GER */
  1374.                         else
  1375. #  if USE_GER
  1376.                           sprintf(s, "|%02d|%*s %s, ", j, len_fil_wt, "",
  1377.                                   short_day_name (weekday_of_date (day, m, y)));
  1378. #  else /* !USE_GER */
  1379.                           sprintf(s, "|%02d|%*s %s, ", j, len_fil_wt, "",
  1380.                                   short3_day_name (weekday_of_date (day, m, y)));
  1381. #  endif /* !USE_GER */
  1382.                       }
  1383.                    }
  1384.                   else
  1385.                    {
  1386.                      if (rc_count_flag)
  1387. #  if USE_GER
  1388.                        sprintf(s, "%0*d)  %s, ", len_rce-3, (line-skip)+1,
  1389.                                short_day_name (weekday_of_date (day, m, y)));
  1390. #  else /* !USE_GER */
  1391.                        sprintf(s, "%0*d)  %s, ", len_rce-3, (line-skip)+1,
  1392.                                short3_day_name (weekday_of_date (day, m, y)));
  1393. #  endif /* !USE_GER */
  1394.                      else
  1395. #  if USE_GER
  1396.                        sprintf(s, "%s, ", short_day_name (weekday_of_date (day, m, y)));
  1397. #  else /* !USE_GER */
  1398.                        sprintf(s, "%s, ", short3_day_name (weekday_of_date (day, m, y)));
  1399. #  endif /* !USE_GER */
  1400.                    }
  1401.                   d = day;
  1402.                   wd = 0;
  1403.                   j = (int)strlen(s);
  1404.                   if (   rc_julian_flag
  1405.                       || rc_both_dates_flag)
  1406.                     d = day_of_year (d, m, y);
  1407.                   hls1_set=hls2_set = FALSE;
  1408. #  if USE_GER
  1409.                   if (   (y == tmp_ay)
  1410.                       && (m == tmp_am)
  1411.                       && (day == tmp_ad))
  1412.                    {
  1413.                      j += 2;
  1414.                      hls1_set = TRUE;
  1415.                      if (rc_both_dates_flag)
  1416.                       {
  1417.                         sprintf(s2, "%*s%s%2d(%3d)%s%*s", !emu_hls, "", ehls1s.seq,
  1418.                                 day, d, ehls1e.seq, !emu_hls, "");
  1419.                         j += 7;
  1420.                       }
  1421.                      else
  1422.                       {
  1423.                         sprintf(s2, "%*s%s%*d%s%*s",
  1424.                                 !emu_hls, "", ehls1s.seq, len, d, ehls1e.seq, !emu_hls, "");
  1425.                         j += len;
  1426.                       }
  1427.                    }
  1428.                   else
  1429.                    {
  1430.                      if (*holiday_vector[m-1])
  1431.                        for (i=0 ; holiday_vector[m-1][i] ; i++)
  1432.                          if (holiday_vector[m-1][i] == ((rc_both_dates_flag||rc_julian_flag) ? day : d))
  1433.                           {
  1434.                             wd = day;
  1435.                             break;
  1436.                           }
  1437.                      if (wd)
  1438.                       {
  1439.                         j += 2;
  1440.                         hls2_set = TRUE;
  1441.                         if (rc_both_dates_flag)
  1442.                          {
  1443.                            sprintf(s2, "%*s%s%2d(%3d)%s%*s", !emu_hls, "", ehls2s.seq,
  1444.                                    day, d, ehls2e.seq, !emu_hls, "");
  1445.                            j += 7;
  1446.                          }
  1447.                         else
  1448.                          {
  1449.                            sprintf(s2, "%*s%s%*d%s%*s", !emu_hls, "", ehls2s.seq,
  1450.                                    len, d, ehls2e.seq, !emu_hls, "");
  1451.                            j += len;
  1452.                          }
  1453.                       }
  1454.                      else
  1455.                       {
  1456.                         if (rc_both_dates_flag)
  1457.                           sprintf(s2, NO_HLS"%2d(%3d)"NO_HLS, day, d);
  1458.                         else
  1459.                           sprintf(s2, NO_HLS"%*d"NO_HLS, len, d);
  1460.                         j += (int)strlen(s2);
  1461.                       }
  1462.                    }
  1463.                   strcat(s, s2);
  1464.                   sprintf(s2, "%s %0*d:",
  1465.                           (rc_julian_flag&&!rc_both_dates_flag)
  1466.                           ? "Tag" : (char *)short_month_name (m), len_year_max, y);
  1467. #  else /* !USE_GER */
  1468.                   sprintf(s2, "%s%s",
  1469.                           (rc_julian_flag&&!rc_both_dates_flag)
  1470.                           ? "" : (char *)short_month_name (m),
  1471.                           (rc_julian_flag&&!rc_both_dates_flag) ? "" : " ");
  1472.                   j += (int)strlen(s2);
  1473.                   strcat(s, s2);
  1474.                   if (   (y == tmp_ay)
  1475.                       && (m == tmp_am)
  1476.                       && (day == tmp_ad))
  1477.                    {
  1478.                      j += 5;
  1479.                      hls1_set = TRUE;
  1480.                      if (rc_both_dates_flag)
  1481.                       {
  1482.                         sprintf(s2, "%*s%s%2d%s(%3d)%s%*s", !emu_hls, "", ehls1s.seq,
  1483.                                 day, day_suffix (day), d, ehls1e.seq, !emu_hls, "");
  1484.                         j += 7;
  1485.                       }
  1486.                      else
  1487.                       {
  1488.                         sprintf(s2, "%*s%s%*d%s%s%*s", !emu_hls, "", ehls1s.seq,
  1489.                                 len, d, day_suffix (d), ehls1e.seq, !emu_hls, "");
  1490.                         j += len;
  1491.                       }
  1492.                    }
  1493.                   else
  1494.                    {
  1495.                      if (*holiday_vector[m-1])
  1496.                        for (i=0 ; holiday_vector[m-1][i] ; i++)
  1497.                          if (holiday_vector[m-1][i] == ((rc_both_dates_flag||rc_julian_flag) ? day : d))
  1498.                           {
  1499.                             wd = day;
  1500.                             break;
  1501.                           }
  1502.                      if (wd)
  1503.                       {
  1504.                         j += 5;
  1505.                         hls2_set = TRUE;
  1506.                         if (rc_both_dates_flag)
  1507.                          {
  1508.                            sprintf(s2, "%*s%s%2d%s(%3d)%s%*s", !emu_hls, "", ehls2s.seq,
  1509.                                    day, day_suffix (day), d, ehls2e.seq, !emu_hls, "");
  1510.                            j += 7;
  1511.                          }
  1512.                         else
  1513.                          {
  1514.                            sprintf(s2, "%*s%s%*d%s%s%*s", !emu_hls, "", ehls2s.seq,
  1515.                                    len, d, day_suffix (d), ehls2e.seq, !emu_hls, "");
  1516.                            j += len;
  1517.                          }
  1518.                       }
  1519.                      else
  1520.                       {
  1521.                         if (rc_both_dates_flag)
  1522.                           sprintf(s2, NO_HLS"%2d%s(%3d)"NO_HLS, day, day_suffix (day), d);
  1523.                         else
  1524.                           sprintf(s2, NO_HLS"%*d%s"NO_HLS, len, d, day_suffix (d));
  1525.                         j += (int)strlen(s2);
  1526.                       }
  1527.                    }
  1528.                   strcat(s, s2);
  1529.                   sprintf(s2, "%s%0*d:",
  1530.                           (rc_julian_flag&&!rc_both_dates_flag) ? "day " : "", len_year_max, y);
  1531. #  endif /* !USE_GER */
  1532.                   j += (int)strlen(s2);
  1533.                   strcat(s, s2);
  1534.                   /*
  1535.                      Check if `ptr_char' must be truncated
  1536.                   */
  1537.                   len_s = (int)strlen(s);
  1538.                   len_ptr_char = (int)strlen(ptr_char);
  1539.                   if (len_s+len_ptr_char >= MAXLEN)
  1540.                     *(ptr_char + (MAXLEN-len_s)) = '\0';
  1541.                   /*
  1542.                      Now modify fixed date text
  1543.                   */
  1544.                   ok = FALSE;
  1545.                   len_fn_part = 0;
  1546.                   /*
  1547.                      "Empty" warnings texts have no trailing space character!
  1548.                   */
  1549.                   if (len_ptr_char > 1)
  1550.                    {
  1551.                      ok = (Bool)(strchr(ptr_char, RC_NL_CHAR) == (char *)NULL);
  1552.                      if (ok)
  1553.                        strcat(s, ptr_char);
  1554.                      else
  1555.                       {
  1556.                         /*
  1557.                            `~'-TILDE or quoted `\~'-TILDE found in `text'-part of fixed date:
  1558.                              quote TILDE resp., insert a real `\n'-NEWLINE character
  1559.                         */
  1560.                         if (rc_enable_fn_flag)
  1561.                          {
  1562.                            auto char  *ptr_fn_part;
  1563.  
  1564.  
  1565.                            /*
  1566.                               Add the length of the filename+3 (+3 because the
  1567.                                 filename itself is leaded by a blank character
  1568.                                 and is enclosed in parantheses --> " (%s)")
  1569.                                 to the number of leading blanks, which must be
  1570.                                 displayed if the line wrapped by a given `~'-TILDE
  1571.                            */
  1572.                            ptr_fn_part = ptr_char;
  1573.                            while (   *ptr_fn_part
  1574.                                   && (*ptr_fn_part != ')'))
  1575.                             {
  1576.                               len_fn_part++;
  1577.                               ptr_fn_part++;
  1578.                             }
  1579.                            if (!*ptr_fn_part)
  1580.                              /*
  1581.                                 Internal error, a maintainer has modified the output
  1582.                                   format of a line and forgots to respect this change here!
  1583.                              */
  1584.                              my_error (99, "", 0, "", 0);
  1585.                            len_fn_part++;
  1586.                          }
  1587.                         while (   *ptr_char
  1588.                                && (len_s < MAXLEN))
  1589.                          {
  1590.                            if (*ptr_char == RC_NL_CHAR)
  1591.                             {
  1592.                               /*
  1593.                                  RC_NL_CHAR is single `\~' quoted
  1594.                                             or double `\\~' quoted:
  1595.                                    replace QUOTE_CHAR by RC_NL_CHAR resp.,
  1596.                                    replace last QUOTE_CHAR by RC_NL_CHAR
  1597.                               */
  1598.                               if (s[len_s-1] == QUOTE_CHAR)
  1599.                                 s[len_s-1] = *ptr_char;
  1600.                               else
  1601.                                {
  1602.                                  /*
  1603.                                     RC_NL_CHAR is not quoted `~':
  1604.                                       insert a real `\n'_NEWLINE character
  1605.                                  */
  1606.                                  s[len_s++] = '\n';
  1607.                                  /*
  1608.                                     Insert `j+len_fn_part+1' leading blanks
  1609.                                  */
  1610.                                  i_dummy = j + len_fn_part + 1;
  1611.                                  for (i=0 ; (i < i_dummy) && (len_s < MAXLEN) ; i++)
  1612.                                    s[len_s++] = ' ';
  1613.                                }
  1614.                             }
  1615.                            else
  1616.                              s[len_s++] = *ptr_char;
  1617.                            ptr_char++;
  1618.                          }
  1619.                         s[len_s] = '\0';
  1620.                       }
  1621.                    }
  1622.                   if (   rc_omit_date_flag
  1623.                       && same_date)
  1624.                    {
  1625.                      /*
  1626.                         Overwrite leading date part with blanks
  1627.                      */
  1628.                      if (rc_count_flag)
  1629.                        i = len_rce;
  1630.                      else
  1631.                        i = 0;
  1632.                      for ( ; i < j ; i++)
  1633.                        s[i] = ' ';
  1634.                      if (ok)
  1635.                       {
  1636.                         s[i] = '\0';
  1637.                         strcat(s, ptr_char);
  1638.                       }
  1639.                      else
  1640.                        if (   (ehls1s.len != 1)
  1641.                            && (   hls1_set
  1642.                                || hls2_set))
  1643.                         {
  1644.                           register int  hls_len=(hls1_set) ? hls1_len : hls2_len;
  1645.  
  1646.  
  1647.                           ptr_char = &s[j+hls_len];
  1648.                           for (i=j ; *ptr_char ; i++)
  1649.                             s[i] = *ptr_char++;
  1650.                           s[i] = '\0';
  1651.                         }
  1652.                    }
  1653.                   /*
  1654.                      Now display constructed fixed date warning message
  1655.                   */
  1656.                   print_text (stdout, s, INternal);
  1657.                 }
  1658.                else
  1659.                  skip++;
  1660.                free(rc_table[line]);
  1661.                rc_table[line] = (char *)NULL;
  1662.              }
  1663.           }
  1664.        }
  1665.     }
  1666.    start_day = tmp_start_day;
  1667.    month = tmp_month;
  1668.    act_day = tmp_ad;
  1669.    act_month = tmp_am;
  1670.    act_year = tmp_ay;
  1671. }
  1672. #endif /* USE_RC */
  1673.